package com.example.demo.mp.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.mp.entity.User;
import com.example.demo.mp.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;


    @Override
    @Transactional
    public User reNewUser(int id) {
        User user = userMapper.selectById(id);
        userMapper.deleteById(id);
        user.setName("uuuuuuuuuuuuuuuuuuu");
        user.setId(id);
        userMapper.insert(user);
//        int i = 1/0;
        return user;
    }
}
